import cv2 as cv
import numpy as np

image = cv.imread(r'temp.jpg')
img = cv.pyrDown(image)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)

cv.imshow('source',img)
cv.imshow('gray',gray)
cv.waitKey()
cv.destroyAllWindows()
hsv = cv.cvtColor(img,cv.COLOR_BGR2HSV)
zeros = np.zeros(img.shape[:2],dtype="uint8")#创建与image相同大小的零矩阵

cv.imshow('HSV',hsv)
#分离三通道
cv.imshow('Hue',hsv[:,:,0])
cv.imshow('Saturation',hsv[:,:,1])
cv.imshow('value',hsv[:,:,2])
cv.waitKey()

B,G,R=cv.split(img)
B=cv.merge([B,zeros,zeros])
G=cv.merge([zeros,G,zeros])
R=cv.merge([zeros,zeros,R])
cv.imshow('B',B)
cv.imshow('G',G)
cv.imshow('R',R)
cv.waitKey()

cv.destroyAllWindows()
